package org.csu.mypetstorems.controller;

import org.csu.mypetstorems.entity.PageBean;
import org.csu.mypetstorems.entity.User;
import org.csu.mypetstorems.result.Result;
import org.csu.mypetstorems.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/user/listWithCondition")
    public Result<PageBean<User>> userListWithConditionService(
            @RequestParam Integer pageNum,
            @RequestParam Integer pageSize,
            @RequestParam(required = false) String userId
    ) {
        PageBean<User> pageBean = userService.getUserListWithCondition(pageNum, pageSize, userId);
        if(pageBean != null)
            return Result.success(pageBean);
        else
            return Result.error("获取User条件查询失败");
    }
}
